/***********************************************
 * Title:       IbatisStudentDao.java
 * Description: TODO ADD DISCRIPTION TO IbatisStudentDao.java
 * Author:      Niyuzhe
 * Create Date: 2009-12-2
 * CopyRight:   CopyRight(c)@2009
 * Company:     TJUSCS
 * Version:     1.0
 ***********************************************
 */
package edu.tju.model;

import java.sql.SQLException;
import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.younker.waf.db.IBatisConfig;


/**
 * @author Niyuzhe
 *
 */
public class IbatisStudentDao implements IStudentDao
{

        protected SqlMapClient sqlMap = IBatisConfig.getSqlMapInstance();
        
        /* (non-Javadoc)
         * @see edu.tju.model.IStudentDao#getStudentById(long)
         */
        public Student getStudentById(long id) throws SQLException
        {
                return (Student)sqlMap.queryForObject("getStudentById", id);
        }

        /* (non-Javadoc)
         * @see edu.tju.model.IStudentDao#getStudentAnd(edu.tju.model.Student)
         */
        public List<Student> getStudentAnd(Student student) throws SQLException
        {       
                return sqlMap.queryForList("getStudentAnd", student);
        }
        
   

        /* (non-Javadoc)
         * @see edu.tju.model.IStudentDao#getStudentOr(edu.tju.model.Student)
         */
        public List<Student> getStudentOr(Student student)
        {
                // TODO To be implemented
                return null;
        }

        /* (non-Javadoc)
         * @see edu.tju.model.IStudentDao#insertStudent(edu.tju.model.Student)
         */
        public long insertStudent(Student student) throws SQLException
        {
                
                
                
                
                return (Long)sqlMap.insert("insertStudent", student);
                

        }

        /* (non-Javadoc)
         * @see edu.tju.model.IStudentDao#updateStudent(edu.tju.model.Student)
         */
        public void updateStudent(Student student) throws SQLException
        {
                sqlMap.update("updateStudent", student);

        }

        /* (non-Javadoc)
         * @see edu.tju.model.IStudentDao#deleteStudent(long)
         */
        public void deleteStudent(long id) throws SQLException
        {
                sqlMap.delete("deleteStudent", id);
        
        }


}
